/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.Bill;

import entities.PatientDetails;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author Dell
 */
public class TableModelPatient implements TableModel {

    private ArrayList<PatientDetails> patientList;
    private String header[];

    public String[] getHeader() {
        return header;
    }

    public void setHeader(String[] header) {
        this.header = header;
    }

    public TableModelPatient(ArrayList<PatientDetails> patientList) {
        this.patientList = patientList;
    }

    public TableModelPatient() {
    }



    @Override
    public int getRowCount() {
        if (patientList != null) {
            return patientList.size();
        } else {
            return 0;
        }
    }

    @Override
    public int getColumnCount() {
        return header.length;
    }

    @Override
    public String getColumnName(int columnIndex) {
        return header[columnIndex];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex == 0 || columnIndex == 1||columnIndex==3) {
            return String.class;
        } else 
            return Date.class;
        

    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return false;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        if (columnIndex == 0) {
            String fullname;
            fullname = patientList.get(rowIndex).getpFName() + ' ' + patientList.get(rowIndex).getpLName();
            return fullname;
        } else if (columnIndex == 1) {
            return patientList.get(rowIndex).getpAddress();
        } else if (columnIndex == 2) {
            return patientList.get(rowIndex).getpDOB();
        }else if(columnIndex==3){
            if(patientList.get(rowIndex).ispGender()){
                return "Male";
            }else{
                return "FeMale";
            }
            
        }
        return null;
    }

    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        //   throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void addTableModelListener(TableModelListener l) {
        //    throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void removeTableModelListener(TableModelListener l) {
        //    throw new UnsupportedOperationException("Not supported yet.");
    }
}
